﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Admin1_Default : System.Web.UI.Page
{
    //Datacon db = new Datacon();
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            //db.ecDropDownList(ddlCourse, "select * from Course where teacher_id='" + Session["ID"] + "'", "c_name", "c_id");          //初始化考试科目下拉列表框          

        }
    }
    protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
    {
        using (DataClassesDataContext ds = new DataClassesDataContext())
        {
            if (cblAnswer.Items[0].Selected == true && cblAnswer.Items[1].Selected == true && cblAnswer.Items[2].Selected == true && cblAnswer.Items[3].Selected == true)
            {
                string strr1 = "ABCD";
                //db.eccom("insert into MultiProblem(c_id,Title,AnswerA,AnswerB,AnswerC,AnswerD,Answer) values('" + Request["ddlCourse"] + "','" + this.txtTitle.Text + "','" + this.txtAnswerA.Text + "','" + this.txtAnswerB.Text + "','" + this.txtAnswerC.Text + "','" + this.txtAnswerD.Text + "','" + strr1 + "')");
                MultiProblem p = new MultiProblem();
                p.c_id = Convert.ToInt32(Request["ddlCourse"]);
                p.Title = this.txtTitle.Text.Trim();
                p.AnswerA = this.txtAnswerA.Text.Trim();
                p.AnswerB = this.txtAnswerB.Text.Trim();
                p.AnswerC = this.txtAnswerC.Text.Trim();
                p.AnswerD = this.txtAnswerD.Text.Trim();
                p.Answer = strr1;
                ds.MultiProblem.InsertOnSubmit(p);
                ds.SubmitChanges();

                Response.Write("<script>alert('添加成功！')</script>");

            }
            if (cblAnswer.Items[0].Selected == true && cblAnswer.Items[1].Selected == true && cblAnswer.Items[2].Selected == true && cblAnswer.Items[3].Selected == false)
            {
                string strr2 = "ABC";
                //db.eccom("insert into MultiProblem(c_id,Title,AnswerA,AnswerB,AnswerC,AnswerD,Answer) values('" + Request["ddlCourse"] + "','" + this.txtTitle.Text + "','" + this.txtAnswerA.Text + "','" + this.txtAnswerB.Text + "','" + this.txtAnswerC.Text + "','" + this.txtAnswerD.Text + "','" + strr2 + "')");
                MultiProblem p = new MultiProblem();
                p.c_id = Convert.ToInt32(Request["ddlCourse"]);
                p.Title = this.txtTitle.Text.Trim();
                p.AnswerA = this.txtAnswerA.Text.Trim();
                p.AnswerB = this.txtAnswerB.Text.Trim();
                p.AnswerC = this.txtAnswerC.Text.Trim();
                p.AnswerD = this.txtAnswerD.Text.Trim();
                p.Answer = strr2;
                ds.MultiProblem.InsertOnSubmit(p);
                ds.SubmitChanges();

                Response.Write("<script>alert('添加成功！')</script>");

            }
            if (cblAnswer.Items[0].Selected == true && cblAnswer.Items[1].Selected == true && cblAnswer.Items[2].Selected == false && cblAnswer.Items[3].Selected == false)
            {
                string strr3 = "AB";
                //db.eccom("insert into MultiProblem(c_id,Title,AnswerA,AnswerB,AnswerC,AnswerD,Answer) values('" + Request["ddlCourse"] + "','" + this.txtTitle.Text + "','" + this.txtAnswerA.Text + "','" + this.txtAnswerB.Text + "','" + this.txtAnswerC.Text + "','" + this.txtAnswerD.Text + "','" + strr3 + "')");
                MultiProblem p = new MultiProblem();
                p.c_id = Convert.ToInt32(Request["ddlCourse"]);
                p.Title = this.txtTitle.Text.Trim();
                p.AnswerA = this.txtAnswerA.Text.Trim();
                p.AnswerB = this.txtAnswerB.Text.Trim();
                p.AnswerC = this.txtAnswerC.Text.Trim();
                p.AnswerD = this.txtAnswerD.Text.Trim();
                p.Answer = strr3;
                ds.MultiProblem.InsertOnSubmit(p);
                ds.SubmitChanges();

                Response.Write("<script>alert('添加成功！')</script>");

            }
            if (cblAnswer.Items[0].Selected == true && cblAnswer.Items[1].Selected == false && cblAnswer.Items[2].Selected == false && cblAnswer.Items[3].Selected == false)
            {
                string strr4 = "A";
                //db.eccom("insert into MultiProblem(c_id,Title,AnswerA,AnswerB,AnswerC,AnswerD,Answer) values('" + Request["ddlCourse"] + "','" + this.txtTitle.Text + "','" + this.txtAnswerA.Text + "','" + this.txtAnswerB.Text + "','" + this.txtAnswerC.Text + "','" + this.txtAnswerD.Text + "','" + strr4 + "')");
                MultiProblem p = new MultiProblem();
                p.c_id = Convert.ToInt32(Request["ddlCourse"]);
                p.Title = this.txtTitle.Text.Trim();
                p.AnswerA = this.txtAnswerA.Text.Trim();
                p.AnswerB = this.txtAnswerB.Text.Trim();
                p.AnswerC = this.txtAnswerC.Text.Trim();
                p.AnswerD = this.txtAnswerD.Text.Trim();
                p.Answer = strr4;
                ds.MultiProblem.InsertOnSubmit(p);
                ds.SubmitChanges();

                Response.Write("<script>alert('添加成功！')</script>");

            }
            if (cblAnswer.Items[0].Selected == false && cblAnswer.Items[1].Selected == true && cblAnswer.Items[2].Selected == false && cblAnswer.Items[3].Selected == false)
            {
                string strr5 = "B";
                //db.eccom("insert into MultiProblem(c_id,Title,AnswerA,AnswerB,AnswerC,AnswerD,Answer) values('" + Request["ddlCourse"] + "','" + this.txtTitle.Text + "','" + this.txtAnswerA.Text + "','" + this.txtAnswerB.Text + "','" + this.txtAnswerC.Text + "','" + this.txtAnswerD.Text + "','" + strr5 + "')");
                MultiProblem p = new MultiProblem();
                p.c_id = Convert.ToInt32(Request["ddlCourse"]);
                p.Title = this.txtTitle.Text.Trim();
                p.AnswerA = this.txtAnswerA.Text.Trim();
                p.AnswerB = this.txtAnswerB.Text.Trim();
                p.AnswerC = this.txtAnswerC.Text.Trim();
                p.AnswerD = this.txtAnswerD.Text.Trim();
                p.Answer = strr5;
                ds.MultiProblem.InsertOnSubmit(p);
                ds.SubmitChanges();

                Response.Write("<script>alert('添加成功！')</script>");

            }
            if (cblAnswer.Items[0].Selected == false && cblAnswer.Items[1].Selected == true && cblAnswer.Items[2].Selected == true && cblAnswer.Items[3].Selected == false)
            {
                string strr6 = "BC";
                //db.eccom("insert into MultiProblem(c_id,Title,AnswerA,AnswerB,AnswerC,AnswerD,Answer) values('" + Request["ddlCourse"] + "','" + this.txtTitle.Text + "','" + this.txtAnswerA.Text + "','" + this.txtAnswerB.Text + "','" + this.txtAnswerC.Text + "','" + this.txtAnswerD.Text + "','" + strr6 + "')");
                MultiProblem p = new MultiProblem();
                p.c_id = Convert.ToInt32(Request["ddlCourse"]);
                p.Title = this.txtTitle.Text.Trim();
                p.AnswerA = this.txtAnswerA.Text.Trim();
                p.AnswerB = this.txtAnswerB.Text.Trim();
                p.AnswerC = this.txtAnswerC.Text.Trim();
                p.AnswerD = this.txtAnswerD.Text.Trim();
                p.Answer = strr6;
                ds.MultiProblem.InsertOnSubmit(p);
                ds.SubmitChanges();

                Response.Write("<script>alert('添加成功！')</script>");

            }
            if (cblAnswer.Items[0].Selected == false && cblAnswer.Items[1].Selected == true && cblAnswer.Items[2].Selected == false && cblAnswer.Items[3].Selected == true)
            {
                string strr7 = "BD";
                //db.eccom("insert into MultiProblem(c_id,Title,AnswerA,AnswerB,AnswerC,AnswerD,Answer) values('" + Request["ddlCourse"] + "','" + this.txtTitle.Text + "','" + this.txtAnswerA.Text + "','" + this.txtAnswerB.Text + "','" + this.txtAnswerC.Text + "','" + this.txtAnswerD.Text + "','" + strr7 + "')");
                MultiProblem p = new MultiProblem();
                p.c_id = Convert.ToInt32(Request["ddlCourse"]);
                p.Title = this.txtTitle.Text.Trim();
                p.AnswerA = this.txtAnswerA.Text.Trim();
                p.AnswerB = this.txtAnswerB.Text.Trim();
                p.AnswerC = this.txtAnswerC.Text.Trim();
                p.AnswerD = this.txtAnswerD.Text.Trim();
                p.Answer = strr7;
                ds.MultiProblem.InsertOnSubmit(p);
                ds.SubmitChanges();

                Response.Write("<script>alert('添加成功！')</script>");

            }
            if (cblAnswer.Items[0].Selected == false && cblAnswer.Items[1].Selected == true && cblAnswer.Items[2].Selected == true && cblAnswer.Items[3].Selected == true)
            {
                string strr8 = "BCD";
                //db.eccom("insert into MultiProblem(c_id,Title,AnswerA,AnswerB,AnswerC,AnswerD,Answer) values('" + Request["ddlCourse"] + "','" + this.txtTitle.Text + "','" + this.txtAnswerA.Text + "','" + this.txtAnswerB.Text + "','" + this.txtAnswerC.Text + "','" + this.txtAnswerD.Text + "','" + strr8 + "')");
                MultiProblem p = new MultiProblem();
                p.c_id = Convert.ToInt32(Request["ddlCourse"]);
                p.Title = this.txtTitle.Text.Trim();
                p.AnswerA = this.txtAnswerA.Text.Trim();
                p.AnswerB = this.txtAnswerB.Text.Trim();
                p.AnswerC = this.txtAnswerC.Text.Trim();
                p.AnswerD = this.txtAnswerD.Text.Trim();
                p.Answer = strr8;
                ds.MultiProblem.InsertOnSubmit(p);
                ds.SubmitChanges();

                Response.Write("<script>alert('添加成功！')</script>");

            }
            if (cblAnswer.Items[0].Selected == true && cblAnswer.Items[1].Selected == false && cblAnswer.Items[2].Selected == false && cblAnswer.Items[3].Selected == true)
            {
                string strr9 = "AD";
                //db.eccom("insert into MultiProblem(c_id,Title,AnswerA,AnswerB,AnswerC,AnswerD,Answer) values('" + Request["ddlCourse"] + "','" + this.txtTitle.Text + "','" + this.txtAnswerA.Text + "','" + this.txtAnswerB.Text + "','" + this.txtAnswerC.Text + "','" + this.txtAnswerD.Text + "','" + strr9 + "')");
                MultiProblem p = new MultiProblem();
                p.c_id = Convert.ToInt32(Request["ddlCourse"]);
                p.Title = this.txtTitle.Text.Trim();
                p.AnswerA = this.txtAnswerA.Text.Trim();
                p.AnswerB = this.txtAnswerB.Text.Trim();
                p.AnswerC = this.txtAnswerC.Text.Trim();
                p.AnswerD = this.txtAnswerD.Text.Trim();
                p.Answer = strr9;
                ds.MultiProblem.InsertOnSubmit(p);
                ds.SubmitChanges();

                Response.Write("<script>alert('添加成功！')</script>");

            }
            if (cblAnswer.Items[0].Selected == false && cblAnswer.Items[1].Selected == false && cblAnswer.Items[2].Selected == true && cblAnswer.Items[3].Selected == true)
            {
                string strr10 = "CD";
                //db.eccom("insert into MultiProblem(c_id,Title,AnswerA,AnswerB,AnswerC,AnswerD,Answer) values('" + Request["ddlCourse"] + "','" + this.txtTitle.Text + "','" + this.txtAnswerA.Text + "','" + this.txtAnswerB.Text + "','" + this.txtAnswerC.Text + "','" + this.txtAnswerD.Text + "','" + strr10 + "')");
                MultiProblem p = new MultiProblem();
                p.c_id = Convert.ToInt32(Request["ddlCourse"]);
                p.Title = this.txtTitle.Text.Trim();
                p.AnswerA = this.txtAnswerA.Text.Trim();
                p.AnswerB = this.txtAnswerB.Text.Trim();
                p.AnswerC = this.txtAnswerC.Text.Trim();
                p.AnswerD = this.txtAnswerD.Text.Trim();
                p.Answer = strr10;
                ds.MultiProblem.InsertOnSubmit(p);
                ds.SubmitChanges();

                Response.Write("<script>alert('添加成功！')</script>");

            }
            if (cblAnswer.Items[0].Selected == true && cblAnswer.Items[1].Selected == false && cblAnswer.Items[2].Selected == true && cblAnswer.Items[3].Selected == false)
            {
                string strr11 = "AC";
                //db.eccom("insert into MultiProblem(c_id,Title,AnswerA,AnswerB,AnswerC,AnswerD,Answer) values('" + Request["ddlCourse"] + "','" + this.txtTitle.Text + "','" + this.txtAnswerA.Text + "','" + this.txtAnswerB.Text + "','" + this.txtAnswerC.Text + "','" + this.txtAnswerD.Text + "','" + strr11 + "')");
                MultiProblem p = new MultiProblem();
                p.c_id = Convert.ToInt32(Request["ddlCourse"]);
                p.Title = this.txtTitle.Text.Trim();
                p.AnswerA = this.txtAnswerA.Text.Trim();
                p.AnswerB = this.txtAnswerB.Text.Trim();
                p.AnswerC = this.txtAnswerC.Text.Trim();
                p.AnswerD = this.txtAnswerD.Text.Trim();
                p.Answer = strr11;
                ds.MultiProblem.InsertOnSubmit(p);
                ds.SubmitChanges();

                Response.Write("<script>alert('添加成功！')</script>");

            }
            if (cblAnswer.Items[0].Selected == true && cblAnswer.Items[1].Selected == true && cblAnswer.Items[2].Selected == false && cblAnswer.Items[3].Selected == true)
            {
                string strr12 = "ABD";
                //db.eccom("insert into MultiProblem(c_id,Title,AnswerA,AnswerB,AnswerC,AnswerD,Answer) values('" + Request["ddlCourse"] + "','" + this.txtTitle.Text + "','" + this.txtAnswerA.Text + "','" + this.txtAnswerB.Text + "','" + this.txtAnswerC.Text + "','" + this.txtAnswerD.Text + "','" + strr12 + "')");
                MultiProblem p = new MultiProblem();
                p.c_id = Convert.ToInt32(Request["ddlCourse"]);
                p.Title = this.txtTitle.Text.Trim();
                p.AnswerA = this.txtAnswerA.Text.Trim();
                p.AnswerB = this.txtAnswerB.Text.Trim();
                p.AnswerC = this.txtAnswerC.Text.Trim();
                p.AnswerD = this.txtAnswerD.Text.Trim();
                p.Answer = strr12;
                ds.MultiProblem.InsertOnSubmit(p);
                ds.SubmitChanges();

                Response.Write("<script>alert('添加成功！')</script>");

            }
            if (cblAnswer.Items[0].Selected == true && cblAnswer.Items[1].Selected == false && cblAnswer.Items[2].Selected == true && cblAnswer.Items[3].Selected == true)
            {
                string strr13 = "ACD";
                //db.eccom("insert into MultiProblem(c_id,Title,AnswerA,AnswerB,AnswerC,AnswerD,Answer) values('" + Request["ddlCourse"] + "','" + this.txtTitle.Text + "','" + this.txtAnswerA.Text + "','" + this.txtAnswerB.Text + "','" + this.txtAnswerC.Text + "','" + this.txtAnswerD.Text + "','" + strr13 + "')");
                MultiProblem p = new MultiProblem();
                p.c_id = Convert.ToInt32(Request["ddlCourse"]);
                p.Title = this.txtTitle.Text.Trim();
                p.AnswerA = this.txtAnswerA.Text.Trim();
                p.AnswerB = this.txtAnswerB.Text.Trim();
                p.AnswerC = this.txtAnswerC.Text.Trim();
                p.AnswerD = this.txtAnswerD.Text.Trim();
                p.Answer = strr13;
                ds.MultiProblem.InsertOnSubmit(p);
                ds.SubmitChanges();

                Response.Write("<script>alert('添加成功！')</script>");

            }
            if (cblAnswer.Items[0].Selected == false && cblAnswer.Items[1].Selected == false && cblAnswer.Items[2].Selected == true && cblAnswer.Items[3].Selected == false)
            {
                string strr14 = "C";
                //db.eccom("insert into MultiProblem(c_id,Title,AnswerA,AnswerB,AnswerC,AnswerD,Answer) values('" + Request["ddlCourse"] + "','" + this.txtTitle.Text + "','" + this.txtAnswerA.Text + "','" + this.txtAnswerB.Text + "','" + this.txtAnswerC.Text + "','" + this.txtAnswerD.Text + "','" + strr14 + "')");
                MultiProblem p = new MultiProblem();
                p.c_id = Convert.ToInt32(Request["ddlCourse"]);
                p.Title = this.txtTitle.Text.Trim();
                p.AnswerA = this.txtAnswerA.Text.Trim();
                p.AnswerB = this.txtAnswerB.Text.Trim();
                p.AnswerC = this.txtAnswerC.Text.Trim();
                p.AnswerD = this.txtAnswerD.Text.Trim();
                p.Answer = strr14;
                ds.MultiProblem.InsertOnSubmit(p);
                ds.SubmitChanges();

                Response.Write("<script>alert('添加成功！')</script>");

            }
            if (cblAnswer.Items[0].Selected == false && cblAnswer.Items[1].Selected == false && cblAnswer.Items[2].Selected == false && cblAnswer.Items[3].Selected == true)
            {
                string strr15 = "D";
                //db.eccom("insert into MultiProblem(c_id,Title,AnswerA,AnswerB,AnswerC,AnswerD,Answer) values('" + Request["ddlCourse"] + "','" + this.txtTitle.Text + "','" + this.txtAnswerA.Text + "','" + this.txtAnswerB.Text + "','" + this.txtAnswerC.Text + "','" + this.txtAnswerD.Text + "','" + strr15 + "')");
                MultiProblem p = new MultiProblem();
                p.c_id = Convert.ToInt32(Request["ddlCourse"]);
                p.Title = this.txtTitle.Text.Trim();
                p.AnswerA = this.txtAnswerA.Text.Trim();
                p.AnswerB = this.txtAnswerB.Text.Trim();
                p.AnswerC = this.txtAnswerC.Text.Trim();
                p.AnswerD = this.txtAnswerD.Text.Trim();
                p.Answer = strr15;
                ds.MultiProblem.InsertOnSubmit(p);
                ds.SubmitChanges();

                Response.Write("<script>alert('添加成功！')</script>");

            }
        }
    }
}